<?php
    $id = $_POST["id"];
    $conn = mysqli_connect("localhost", "root", "123456", "sbeam");

    $result = mysqli_query($conn, "SELECT * FROM cart where id='$id'");
    // 判断有没有查询到内容
    // $info = mysqli_num_rows($result);
    $info = mysqli_fetch_assoc($result);
    $arr = json_decode($info['cart'],true);
    if($info === null){
        echo json_encode(array("error" => 1, "data" => "请求购物车失败，检查数据库和服务器"));
    }else{
        echo json_encode(array("error" => 0, "data" => $arr));
    }
?>